package com.goods.controller.business;

import com.goods.business.service.InStockService;
import com.goods.common.model.business.InStock;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.InStockVO;
import com.goods.common.vo.system.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 入库记录页面
 */
@RestController
@RequestMapping("/business/inStock")
public class InStockController {
    @Autowired
    private InStockService inStockService;

    //加载表格数据
    @GetMapping("/findInStockList")
    public ResponseBean findInStockList(@RequestParam Map<String,Object> map){
        PageVO<InStockVO> pageVO = inStockService.findInStockList(map);
        return ResponseBean.success(pageVO);
    }

    //移入到回收站
    @PutMapping("/remove/{id}")
    public ResponseBean remove(@PathVariable Long id){
        inStockService.remove(id);
        return ResponseBean.success();
    }

    //还原到已入库
    @PutMapping("/back/{id}")
    public ResponseBean back(@PathVariable Long id){
        inStockService.back(id);
        return ResponseBean.success();
    }

    //删除
    @GetMapping("/delete/{id}")
    public ResponseBean delete(@PathVariable Long id){
        inStockService.delete(id);
        return ResponseBean.success();
    }

    //添加
    @PostMapping("/addIntoStock")
    public ResponseBean addIntoStock(@RequestBody InStockVO inStockVO){
        inStockService.addIntoStock(inStockVO);
        return ResponseBean.success();
    }

    //通过审核
    @PutMapping("/publish/{id}")
    public ResponseBean publish(@PathVariable Long id){
        inStockService.publish(id);
        return ResponseBean.success(id);
    }

}
